<template>
  <div>
    <crumbs :BreadCrumb="BreadCrumb"></crumbs>
    <div>
      <el-form
          ref="formline"
          :inline="true"
          :model="formInline"
          class="demo-form-inline"
          label-width="90px"
      >
          <el-form-item label="合同名称">
            <el-input v-model="formInline.cname" clearable></el-input>
          </el-form-item>
          <el-form-item label="单位名称">
            <el-input v-model="formInline.enterpriseName" clearable></el-input>
          </el-form-item>
          <el-form-item label="单位负责人">
            <el-input v-model="formInline.enterpriseLead" clearable></el-input>
          </el-form-item>
          <el-form-item label-width="110px" label="签订时间">
            <el-date-picker
              v-model="orderDateRange"
              type="daterange"
              placeholder="选择日期"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="销售人员">
            <el-input v-model="formInline.personName" clearable></el-input>
          </el-form-item>
          <el-form-item label="合同状态">
            <el-select v-model="formInline.status" clearable>
              <el-option v-for="(v, i) in contractStatus" :key="i" :label="v.label" :value="v.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button icon="el-icon-search" type="primary" @click="getqueryContract()"></el-button>
            <el-button type="primary" @click="adddinglog()">新建合同</el-button>
          </el-form-item>
      </el-form>
    </div>
    <div>
      <el-table
          ref="multipleTable"
          :data="tableDatalist"
          tooltip-effect="dark"
          style="width: 100%"
          @selection-change="handleSelectionChange"
      >
        <!-- <el-table-column type="selection" width="55"> </el-table-column> -->
        <!-- <el-table-column sortable  prop="orderNo" label="体检单号" width="120">
        </el-table-column> -->
        <el-table-column prop="enterpriseName" label="单位名称" width="120">
        </el-table-column>
        <el-table-column prop="cname" label="合同名称" width="120">
        </el-table-column>
        <el-table-column prop="cnum" label="合同编号" width="120">
        </el-table-column>
        <el-table-column prop="medicalType" label="体检类型" width="120">
          <template slot-scope="scope">{{formatType(scope.row.medicalType)}}</template>
        </el-table-column>
        <el-table-column label="签订日期" width="200">
          <template slot-scope="scope">
            {{ formatTimes(scope.row.orderDate) }}
          </template>
        </el-table-column>
        <el-table-column label="有效日期" width="200">
          <template slot-scope="scope">
            {{ formatTimes(scope.row.endDate) }}
          </template>
        </el-table-column>
        <el-table-column prop="enterpriseLead" label="单位负责人" width="120">
        </el-table-column>
        <el-table-column prop="enterpriseTel" label="联系方式" width="120">
        </el-table-column>
        <el-table-column prop="personName" label="销售人员" width="120">
        </el-table-column>
        <el-table-column prop="discount" label="折扣率" width="120">
        </el-table-column>
        <el-table-column label="合同状态" width="120">
          <template slot-scope="scope">
            {{ scope.row.status| formatContractStatus }}
          </template>
        </el-table-column>
        <el-table-column prop="memberCount" label="成员人数" width="120">
        </el-table-column>
        <el-table-column prop="checkCount" label="登记人数" width="120">
        </el-table-column>
        <el-table-column prop="editor" label="编辑人" width="120">
        </el-table-column>
        <el-table-column label="操作" width="200" fixed="right">
          <template slot-scope="scope">
            <el-button v-if="scope.row.status===0 || scope.row.status===3" @click="handleClick(scope.row,'edit')" type="primary" size="small">编辑</el-button>
            <el-button v-if="scope.row.status===1 || scope.row.status===2" @click="handleClick(scope.row,'view')" type="primary" size="small">查看</el-button>
            <el-button v-if="scope.row.status===0 || scope.row.status===3"  @click="remove(scope.row)" type="danger" size="small">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pagination">
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNo"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
      </el-pagination>
    </div>
    <!--新建合同-->
    <el-dialog
        :title="title"
        :visible.sync="dialogFormVisible"
        width="90%"
        class="top_dialog"
    >
      <el-form :model="form" :rules="rules" ref="ruleForm" label-position="left">
        <div class="list">
          <el-row :gutter="20">
            <el-col :span="8">
              <div class="info_l_head">
                <div>新建合同信息</div>
                <el-divider></el-divider>
              </div>
              <el-form :model="form">
                <div>
                  <el-form-item label="单位名称" :label-width="formLabelWidth">
                    <el-input v-model="enterpriseName" style="width: 200px;margin-right: 10px;"></el-input>
                    <el-button @click="readEnterpriseList">选择</el-button>
                  </el-form-item>
                  <el-form-item label="合同编号" :label-width="formLabelWidth">
                    <el-input v-model="form.cnum" disabled></el-input>
                  </el-form-item>
                  <el-form-item label="合同名称" :label-width="formLabelWidth">
                    <el-input v-model="form.cname"></el-input>
                  </el-form-item>
                  <div class="info_sel">
                    <div class="info_sel_l">
                      <el-form-item label="签订日期" :label-width="formLabelWidth">
                        <el-date-picker
                            v-model="form.orderDate"
                            type="date"
                            placeholder="选择日期"
                            value-format="yyyy-MM-dd"
                            style="width: 150px;">
                        </el-date-picker>
                      </el-form-item>

                      <el-form-item label="生效日期" :label-width="formLabelWidth">
                        <el-date-picker
                            v-model="form.effectiveDate"
                            type="date"
                            placeholder="选择日期"
                            value-format="yyyy-MM-dd"
                            style="width: 150px;">
                        </el-date-picker>
                      </el-form-item>

                      <el-form-item label="付款方式" :label-width="formLabelWidth">
                        <el-select v-model="form.payMode">
                          <el-option label="银行转账" :value=1></el-option>
                          <el-option label="支票" :value=2></el-option>
                          <el-option label="支付宝" :value=3></el-option>
                          <el-option label="银行卡" :value=4></el-option>
                          <el-option label="其他" :value=5></el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item label="折扣率" :label-width="formLabelWidth">
                        <el-input-number :min="0" :max="1.0" :step="0.1"  :precision="2" v-model="form.discount"></el-input-number>
                      </el-form-item>
                    </div>
                    <div class="info_sel_r">
                      <el-form-item label="签订人" :label-width="formLabelWidth">
                        <el-input v-model="form.linker"></el-input>
                      </el-form-item>
                      <el-form-item label="有效日期" :label-width="formLabelWidth">
                        <el-date-picker
                            v-model="form.endDate"
                            type="date"
                            placeholder="选择日期"
                            style="width: 150px;">
                        </el-date-picker>
                      </el-form-item>
                      <el-form-item label="体检类型" :label-width="formLabelWidth">
                        <el-select v-model="form.medicalType">
                          <el-option v-for="(v, i) in dict.tyType" :key="i" :label="v.itemName" :value="v.itemCode"></el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item label="销售人员" :label-width="formLabelWidth">
                        <el-select v-model="form.personId">
                          <el-option v-for="(item,index) in sellerlist"
                                     :key="item.value"
                                     :label="item.label"
                                     :value="item.value">
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </div>
                  </div>
                  <el-form-item label="备注" :label-width="formLabelWidth">
                    <el-input type="textarea" v-model="form.remark"></el-input>
                  </el-form-item>
                  <el-form-item label="合同状态" :label-width="formLabelWidth">
                    {{form.status | formatContractStatus}}
                  </el-form-item>
                </div>
              </el-form>
            </el-col>
            <el-col :span="15" :offset="1">
              <div class="info_r">
                <!-- @tab-click="groupnameinit" -->
                <el-tabs v-model="activeName">
                  <el-tab-pane label="分组管理" name="first">
                    <div v-if="title==='编辑合同'">
                      <el-form :inline="true" :model="groupform" class="demo-form-inline" @submit.native.prevent>
                        <el-form-item label="分组名称">
                          <el-input v-model="groupform.groupName"></el-input>
                        </el-form-item>
                        <el-form-item label="选择分组模板">
                          <el-select v-model="groupform.groupId" value-key="id" @change="selectGroup">
                            <el-option
                                v-for="(item,index) in groupOptions"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id"
                            ></el-option>
                          </el-select>
												</el-form-item>
                        <el-form-item>
                          <el-button v-if="title==='编辑合同'" type="primary" @click="addGroup()">添加</el-button>
                        </el-form-item>
                      </el-form>
                    </div>
                    <el-table
                        :data="groupList"
                        :row-key="getRowKey"
                        style="width: 100%"
                        border
                    >
                      <el-table-column
                          prop="groupName"
                          label="分组名称">
                      </el-table-column>
                      <el-table-column
                          prop="groupIndx"
                          label="适用范围">
                        <template slot-scope="scope">
                          <span>{{ scope.row.groupIndx | formatApplyTo }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column
                          prop="groupMarriage"
                          label="婚姻条件">
                        <template slot-scope="scope">
                          <span>{{ scope.row.groupMarriage|formatMarriage }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column
                          prop="groupAge"
                          label="年龄条件">
                        <template slot-scope="scope">
                          <span>{{ scope.row.groupAge|formatAge }} </span>
                          <span v-if="scope.row.groupAge>0">{{ scope.row.ageRange }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column
                          prop="discountPrice"
                          label="总价">
                      </el-table-column>
                      <el-table-column
                          prop="personCount"
                          label="人数">
                      </el-table-column>
                      <el-table-column label="操作" fixed="right" width="240" v-if="title==='编辑合同'">
                        <template slot-scope="scope">
                          <el-button @click="editGroup(scope.row)" size="small" type="primary">修改</el-button>
                          <el-button size="small" type="danger" @click="deletegroupinfo(scope.row)" v-if="scope.row.personCount===0">删除</el-button>
                          <el-button size="small" type="info" @click="valuetitle(scope.row)">体检项目</el-button>
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-tab-pane>
                  <el-tab-pane label="参检人员名单" name="second">
                    <div class="exright">
                      <el-form :inline="true" :model="checkPerson" class="demo-form-inline">
                        <el-form-item label="姓名">
                          <el-input v-model="checkPerson.name" clearable></el-input>
                        </el-form-item>
                        <el-form-item label="分组">
                          <el-select v-model="checkPerson.id" clearable>
                            <el-option v-for="(v,i) in groupList" :key="i" :label="v.groupName" :value="v.id"></el-option>
                          </el-select>
                        </el-form-item>
                        <el-form-item>
                          <el-button type="primary" @click="queryGroupPersons">查询</el-button>
                        </el-form-item>

                        <el-form-item v-if="title==='编辑合同' || form.status!== 0">
                          <el-button type="warning" @click="deleteGroupPersons">删除</el-button>
                        </el-form-item>
                        <el-form-item v-if="title==='编辑合同' || form.status!== 0">
                          <el-upload
                              action="#"
                              :auto-upload="false"
                              :multiple="false"
                              :show-file-list="false"
                              :on-change="uploadByJsqd"
                              :file-list="fileList"
                          >
                            <el-button type="primary">excel导入</el-button>
                          </el-upload>
                        </el-form-item>
                      </el-form>
                    </div>
                    <el-table
                        ref="multipleTable"
                        :data="personList"
                        :row-key="getRowKey"
                        height="500"
                        style="width: 100%"
                        border
                        tooltip-effect="dark"
                        @selection-change="selectGroupPersons"
                    >
                      <el-table-column type="selection" :reserve-selection="true" width="55" align="center">
                      </el-table-column>
                      <el-table-column
                          prop="customerName"
                          label="姓名"
                          width="80">
                      </el-table-column>
                      <el-table-column
                          label="性别"
                          width="80">
                        <template slot-scope="scope">
                          <span>{{ scope.row.sex | formatSex }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column
                          width="80"
                          prop="age"
                          label="年龄">
                      </el-table-column>
                      <el-table-column
                          width="120"
                          label="出生日期">
                        <template slot-scope="scope">
                          <span>{{ formatDate(scope.row.birth) }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column
                          width="80"
                          prop="nativePlace"
                          label="籍贯">
                      </el-table-column>
                      <el-table-column
                          width="80"
                          prop="folk"
                          label="民族">
                      </el-table-column>
                      <el-table-column
                          width="200"
                          prop="credNum"
                          label="身份证证号">
                      </el-table-column>
                      <el-table-column
                          width="80"
                          label="婚姻状态">
                        <template slot-scope="scope">
                          <span>{{ scope.row.marriage | formatMarriage }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column
                          width="120"
                          prop="telephone"
                          label="手机号">
                      </el-table-column>
                      <el-table-column
                          width="80"
                          prop="deptname"
                          label="二级部门">
                      </el-table-column>
                      <el-table-column
                          width="80"
                          prop="groupName"
                          label="所在分组">
                      </el-table-column>
                      <el-table-column label="操作" fixed="right" width="220" v-if="title==='编辑合同' || form.status!== 0">
                        <template slot-scope="scope">
                          <el-button @click="editGroupPersons(scope.row)" size="mini">编辑</el-button>
                          <el-button @click="deleteGroupPerson(scope.row)" size="mini">删除</el-button>
                          <el-button type="primary" size="mini" @click="regroup(scope.row)">分组</el-button>

                        </template>
                      </el-table-column>
                    </el-table>
										<div style="padding: 20px;font-size: 18px;">共{{totalperson}}项, 男={{mannum}}, 女={{womannum}}</div>
                  </el-tab-pane>
                </el-tabs>
              </div>
            </el-col>
          </el-row>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button v-if="title==='编辑合同'" type="success" @click="addContractinfo('ruleForm')">保 存</el-button>
        <el-button v-if="title==='编辑合同'" type="primary" @click="activeContract">立即生效</el-button>
        <el-button type="info" @click="queryalllist">取消</el-button>
      </div>
    </el-dialog>

    <!-- 单位名称选择 -->
    <el-dialog
        title="选择单位"
        :visible.sync="dialogFormVisible3"
        width="60%"
        class="top_dialog"
    >
      <div>
        <el-row>
          <el-col :span="24">
            <div class="ifunit">
              <el-input v-model="roleName" placeholder="请输入查询关键词"></el-input>
              <el-button @click="querycompany()">查找</el-button>
            </div>
            <div>
              <el-table
                  ref="multipleTable1"
                  :data="tableData3"
                  tooltip-effect="dark"
                  width="100%"
                  @select="selectCompany">
                <el-table-column
                    type="selection"
                    width="55">
                </el-table-column>
                <el-table-column
                    prop="name"
                    label="单位名称"
                    width="120">
                </el-table-column>
                <el-table-column
                    prop="linker"
                    label="联系人"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                    prop="linkTel"
                    label="联系人电话"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                    prop="mangeGrade"
                    label="会员级别"
                    show-overflow-tooltip>
                </el-table-column>
              </el-table>
            </div>
          </el-col>
        </el-row>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="choiceCompanyid()">保 存</el-button>
        <el-button @click="dialogFormVisible3 = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="体检项目" width="90%" :visible.sync="outerVisible1" class="top_dialog" append-to-body>
      <el-row :gutter="20" class="bg-grey">
        <el-col :span="11">
          <div class="tableTitle">
            <el-form
                :inline="true"
                :model="examItemSearchForm"
                class="demo-form-inline"
            >
              <el-form-item>
                <el-input
                    v-model="examItemSearchForm.itemName"
                    placeholder="项目名称"
                ></el-input>
              </el-form-item>
              <el-form-item>
                <el-button @click="getexamItemList">查找</el-button>
              </el-form-item>
            </el-form>
          </div>
          <!-- :key="tableKey" -->
          <div class="bg-blue">
            <!-- :key="tableKey" -->
            <el-table
                ref="staffTable"
                :data="staffList"
                max-height="500"
                :row-key="getRowKey"
                border
                fit
                highlight-current-row
                @selection-change="handleStaffChange"
            >
              <el-table-column type="selection" :reserve-selection="true" width="55" align="center"></el-table-column>
              <el-table-column label="科室名称" align="center">
                <template slot-scope="{ row }">
                  <span>{{ row.deptName }}</span>
                </template>
              </el-table-column>

              <el-table-column label="项目名称" align="center">
                <template slot-scope="{ row }">
                  <span>{{ row.itemName }}</span>
                </template>
              </el-table-column>

              <el-table-column label="价格" align="center">
                <template slot-scope="{ row }">
                  <span>{{ row.price }}</span>
                </template>
              </el-table-column>

              <el-table-column label="适用范围" align="center">
                <template slot-scope="{ row }">
                  <span>{{ row.applyTo|formatApplyTo }}</span>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-col>
        <el-col :span="2" align="center" class="buttonAll" style="padding-top: 140px;">
          <el-button @click="addStaff('single')" type="primary" :disabled="!staffData.length" class="staffButton">
            <i class="el-icon-arrow-right"></i>
            <i class="el-icon-arrow-right"></i>
          </el-button>
          <br>
          <el-button
              @click="removeStaff('single')"
              type="primary"
              :disabled="!selectedStaffData.length"
              class="staffButton"
          >
            <i class="el-icon-arrow-left"></i>
            <i class="el-icon-arrow-left"></i>
          </el-button>
        </el-col>
        <el-col :span="11">
          <div class="tableTitle pb-20">
            当前体检项目列表（{{ selectedStaffList.length }}项）
            <div class="nsm-right-top">
              <el-button type="primary" @click="setmeal">选择体检套餐</el-button>
            </div>
          </div>
          <div class="bg-blue">
            <el-table
                ref="selectedStaffTable"
                :data="selectedStaffList"
                max-height="490"
                :row-key="getRowKey"
                border
                fit
                highlight-current-row
                @selection-change="handleSelectedStaffChange"
            >
              <el-table-column type="selection" :reserve-selection="true" width="55" align="center"></el-table-column>
              <el-table-column label="项目名称" align="center">
                <template slot-scope="{ row }">
                  <span>{{ row.itemName }}</span>
                </template>
              </el-table-column>
              <el-table-column label="价格" align="center">
                <template slot-scope="{ row }">
                  <span>{{ row.price }}</span>
                </template>
              </el-table-column>
              <el-table-column label="适用范围" align="center">
                <template slot-scope="{ row }">
                  <span>{{ row.applyTo|formatApplyTo }}</span>
                </template>
              </el-table-column>
              <el-table-column label="缴费方式" align="center">
                <template slot-scope="{ row }">
                  <span>{{ row.payaway || '单位' }}</span>
                </template>
              </el-table-column>
              <el-table-column label="是否缴费" align="center">
                <template slot-scope="{ row }">
                  <span>{{ row.ispay || '已缴费' }}</span>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <el-row>
            <el-col :span="12">分组名称: {{ groupn }}</el-col>
            <el-col :span="12" style="text-align: right;">
              金额合计:
              <span style="font-size: 200%;color: #f00;border: 1px solid #000;padding: 4px 10px;">
								{{ originalprice }}
							</span>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
      <el-row style="margin-top: 30px;" type="flex" align="middle">
        <el-col :span="24" style="text-align: right;padding-bottom: 20px;">
          <el-button type="primary" @click="sendtotal">保存并返回</el-button>
          <el-button @click="outerVisible1 = false">取 消</el-button>
        </el-col>
      </el-row>

    </el-dialog>

    <el-dialog
        title="选择套餐"
        :visible.sync="setmealis"
        width="70%"
        class="top_dialog"
        append-to-body
    >
      <el-form :inline="true" :model="packageSearchForm" class="demo-form-inline">
        <el-form-item label="">
          <el-input
              v-model="packageSearchForm.packageName"
              placeholder="输入查询关键词"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="readPackageList">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
          ref="multipleTable1"
          :data="packageList"
          tooltip-effect="dark"
          border
          style="width: 100%"
          @select="selectrow1"
      >
        <el-table-column type="selection" width="40"></el-table-column>
        <el-table-column prop="packageCode" label="套餐编号"></el-table-column>
        <el-table-column prop="packageName" label="套餐名称"></el-table-column>
        <el-table-column prop="code" label="代码" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="packageType" label="体检类型" show-overflow-tooltip>

        </el-table-column>
        <el-table-column
            prop="applyTo"
            label="适用范围"
            width="80"
            show-overflow-tooltip
        >
          <template slot-scope="scope">{{ scope.row.applyTo|formatApplyTo }}</template>
        </el-table-column>
        <el-table-column
            prop="price"
            label="价格"
            width="80"
            show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
            prop="unitName"
            label="单位名称"
            show-overflow-tooltip
        >
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="savemealis">确定
        </el-button>
        <el-button @click="setmealis = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 参检人员编辑 -->
    <el-dialog :visible.sync="compileis" width="1300px" class="top_dialog">
      <userinfos ref="riskForm" :queryform="queryform"></userinfos>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" style="margin-right:150px;" @click="checkSign()">保存并继续</el-button>
        <el-button @click="compileis = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="修改分组" :visible.sync="dialogroupedit" width="600px" append-to-body>
      <el-form ref="editForm" :model="editForm">
        <el-form-item label="分组名称" label-width="80px">
          <el-input v-model="editForm.groupName"></el-input>
        </el-form-item>
        <el-form-item label="适用范围" label-width="80px">
          <el-select v-model="editForm.groupIndx" style="width: 100%">
            <el-option v-for="(item,index) in optionsSex" :key="item.value" :label="item.label"
                       :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="婚姻分组" label-width="80px">
          <el-select v-model="editForm.groupMarriage" style="width: 100%">
            <el-option v-for="(item,index) in optionsMarriage" :key="item.value" :label="item.label"
                       :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="年龄分组" label-width="80px">
          <el-select v-model="editForm.groupAge" @change="getage" style="width: 100%">
            <el-option v-for="(item,index) in groupAge" :key="item.value" :label="item.label"
                       :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="年龄限制" v-show="ageRange" label-width="80px">
          <el-input v-model="editForm.ageRange"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="editgroupinfo">确 定</el-button>
        <el-button @click="dialogroupedit = false">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 人员分组 -->
    <el-dialog :visible.sync="groupnamedialog" width="50%" class="top_dialog">
      <el-table
          ref="multipleTable1"
          :data="groupList"
          tooltip-effect="dark"
          style="width: 100%"
          :row-key="getRowKey"
          @select="selectrow">
        <el-table-column
            type="selection"
            width="55">
        </el-table-column>
        <el-table-column
            prop="groupName"
            label="分组名称">
        </el-table-column>
        <el-table-column
            prop="groupIndx"
            label="适用范围">
          <template slot-scope="scope">
            <span>{{ scope.row.groupIndx | formatApplyTo }}</span>
          </template>
        </el-table-column>
      </el-table>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" style="margin-right:20px;" @click="regroup()">确定</el-button>
        <el-button @click="groupnamedialog = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script lang="ts">
import {formatTimeToStr} from "@src/common/utils/date";
import {optionsSex, optionsMarriage, groupAge, contractStatus} from "@src/common/utils/constant";
import crumbs from "../../views/Crumbs.vue";
import userinfos from "../common/userinfos.vue";

export default {
  components: {
    crumbs,
    userinfos,
  },
  data() {
    return {
      dict: {},
      contractStatus: contractStatus,
      optionsSex: optionsSex,
      optionsMarriage: optionsMarriage,
      groupAge: groupAge,
      sellerlist: [],
      groupid: "",
      originalprice: 0,
      // 下拉列表内容从数据字典获取
      options1: ["从数字字典修改添加", "从数字字典修改添加"],
      options2: ["从数字字典修改添加"],

      // 体检项目
      mid: "",
      refresh: false,
      groupn: "",
      groupCur: {},
      outerVisible1: false,
      // 分组信息修改
      editForm: {
        ageRange: ''
      },
      dialogroupedit: false,
      title: "编辑合同",
      action:'edit',
      cid: '',
      // 参检人员查询
      checkPerson: {},
      idgroup: [],
      value: "",
      compileis: false,
      labelwidth: '100px',
      formLabelWidth: '80px',
      checkpersoninfo: {},

      fileList: [], //上传的文件列表, 例如: [{name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg'}]
      // limit为上传个数（如果为1，那么只能上传一次，除二次调用需刷新页面）
      limitUpload: 100, //允许上传次数
      // 合同分组
      groupform: {
        groupName:''
      },
			groupOptions: [],
			groupMap: [],
      roleName: "",
      value1: "",
      formlist: {},
      activeName: 'first',
      BreadCrumb: [
        {path: "", name: "检前管理"},
        {path: "/front/contract", name: "团检管理"},
      ],
      // 弹窗
      dialogFormVisible: false,
      dialogFormVisible2: false,
      dialogFormVisible3: false,
      tableDatalist: [],
      tableData: [],
      groupList: [],
      // 参检人员data
      personList: [],
			totalperson: 0,
			mannum: 0,
			womannum: 0,
      tdgroup: [],
      // 单位列表
      tableData3: [],
      enterpriseId: "",
      enterpriseName: "",
      personSel: {},
      personsSel: [],
      companySel: {},
      // 验证新建合同
      rules: {
      },
      // 验证新建单位
      rules1: {
      },
      // 页码
      pageSize: 10,
      pageNo: 1,
      total: 0,
      multipleTablelist: [],
      id: null,
      // 新建合同返回的信息
      callbackdata: {},
      checkform: {},
      checkpersonid: "",
      queryform: {},
      ageRange: false,
      ageRangea: false,
      childflag: false,

      isLinkDept: false,
      form: {
        status:0
      },
      nsmAll: false,
      formInline: {},
      orderDateRange:[
        formatTimeToStr(new Date(), "yyyy-MM-dd"),
        formatTimeToStr(new Date(new Date().getTime() + 24*60*60*1000), "yyyy-MM-dd")
      ],
      listgeren: [],
      // select全选
      multipleSelection: [],
      // 原价合计
      // originalprice: 0,
      costprice: 0,
      // 待选
      staffList: [],
      // listLoading: true,
      // 待选选中
      staffData: [],
      // 总数
      staffNum: 0,
      // 选中数量
      staffCheckNum: 0,
      // 已选选中
      selectedStaffData: [],
      // 已选总数
      selectedStaffNum: 0,
      // 已选选中数量
      selectedStaffCheckNum: 0,
      // 已选列表
      selectedStaffList: [],
      // 添加单项
      inspectionitemis: false,
      inspectionitemlistis: [],
      inspectionitemlist: [],
      // 选择套餐
      setmealis: false,
      packageList: [],
      packageSearchForm: {},
      packagearr: {},
      examItemSearchForm: {},
      groupnamedialog:false
    };  //return
  },  //data
  filters: {
    formatContractStatus:function (val){
      var dict={}
      contractStatus.forEach(v=>{
        dict[v.value] =v.label
      })
      return dict[val]
    },
    formatSex: function (val) {
      var dict = {1: "男", 2: "女"}
      return dict[val]
    },
    formatType: function (val) {
      var dict = {1: "普通体检", 2: "单位体检", 3: "入职体检", 4: "职业体检", 5: "婚育体检", 6: "老年专项体检", 7: "健康体检等"}
      return dict[val]
    },
    formatStatus: function (val) {
      var dict = {1: "未登记", 2: "登记", 4: "检中", 8: "交表", 16: "初检", 32: "复检", 64: "打印"}
      return dict[val]
    },
    formatDate: function (time) {
      if (time != null && time !== "") {
        var date = new Date(time);
        return formatTimeToStr(date, "yyyy-MM-dd hh:mm");
      } else {
        return "";
      }
    },
    formatApplyTo: function (val) {
      var dict = {}
      optionsSex.forEach(v => {
        dict[v.value] = v.label
      })
      return dict[val]
    },
    formatMarriage: function (val) {
      var dict = {}
      optionsMarriage.forEach(v => {
        dict[v.value] = v.label
      })
      return dict[val]
    },
    formatAge: function (val) {
      var dict = {}
      groupAge.forEach(v => {
        dict[v.value] = v.label
      })
      return dict[val]
    }
  },
  watch: {
    selectedStaffList(newValue) {
      this.originalprice = 0;
      console.log(newValue)
      this.getSummaries();
    },
  },
  created() {
    this.getqueryContract();
    this.queryPbPersonsList();
    this.searchDictList()
  },

  methods: {
    selectrow(selection, row) {
		  this.selectinfo = row;
			// console.log("选中的信息: ",this.selectinfo);
		  if (selection.length > 1) {
		    let del_row = selection.shift()
		    this.$refs.multipleTable1.toggleRowSelection(del_row, false) // 用于多选表格，切换某一行的选中状态，如果使用了第二个参数，则是设置这一行选中与否（selected 为 true 则选中）
		  }
		},
    searchDictList() {
      this.$axios.searchDictList({codes: ["tyType"],}).then((res) => {
        if (res.code === "00000") {
          res.data.forEach(v => {
            this.dict[v.dictCode] = v.items
          })
        }
      });
    },
    formatType(val){
      const map = {}
      this.dict.tyType.forEach(v=>{
        map[v.itemCode] = v.itemName
      })
      if(map[val] !== undefined){
        return map[val]
      }
      return val
    },
    // 条件查询合同列表
    getqueryContract() {
      if (this.orderDateRange && this.orderDateRange.length === 2) {
        this.formInline['orderStartDate'] = this.orderDateRange[0]
        this.formInline['orderEndDate'] = this.orderDateRange[1]
      }else {
        delete this.formInline.orderStartDate
        delete this.formInline.orderEndDate
      }

      this.$axios.getPeEnterpriseContractsList({
        ...this.formInline
      }).then(res => {
        if (res.code == '00000') {
          this.tableDatalist = res.data.records;
        }
      })
    },
    // 每页几条
    handleSizeChange(val) {
      this.pageSize = val
      this.doGetList()
    },
    // 第几页
    handleCurrentChange(val) {
      this.pageNo = val
      this.doGetList()
    },
    doGetList(req) {
      this.$axios.getPeEnterpriseContractsList(req).then(res => {
        if (res.code == '00000') {
          this.tableDatalist = res.data.records
          this.total = res.data.total
        }
        // console.log(res)
      })
    },
    queryalllist() {
      this.dialogFormVisible = false
      this.getqueryContract();
    },
    // 销售人员
    queryPbPersonsList() {
      this.$axios.queryPbPersonsList({
        "post": 1
      }).then(res => {
        if (res.code == '00000') {
          let arr = res.data.records
          arr.forEach(item => {
            this.sellerlist.push({
              "label": item.personName,
              "value": item.id
            })
          })
        }
      })
    },


    // 根据分组查询体检项目
    examItemList(params) {
      this.$axios.examItemList(params).then(res => {
        if (res.code == '00000') {
          this.staffList = res.data.records
        }
      })
    },
    // 已保存项目明细
    medicalDetail(groupid) {
      this.selectedStaffList = []
      this.$axios.getPeContractsGroupItemById({
        id: groupid
      }).then(res => {
        if (res.code == '00000') {
          res.data.peContractsGroupItemsList.forEach(v=>{
            this.selectedStaffList.push({...v, id:v.itemId})
          })
        }
      })
    },

    // 参检人员--增删改查
    queryGroupPersons() {
      let obj = {
        contractId: this.id,
        ...this.checkPerson
      }
      this.getGroupPersons(obj)
    },
    selectGroupPersons(rows){
      this.personsSel = rows
    },



    getGroupPersons(params) {
      this.mannum=0
      this.womannum=0
      this.$axios.getPersonGroupById({
        ...params
      }).then(res => {
        if (res.code == '00000') {
          this.personList = res.data;
          this.totalperson = this.personList.length
          this.personList.forEach(item => {
            if (item.sex == 1) {
              this.mannum++;
            } else if (item.sex == 2) {
              this.womannum++;
            }
          })
        }
      })
    },
    deleteGroupPerson(row) {
      this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.deletePeContractsGroupPersons({
          id: row.groupPersonId
        }).then(res => {
          if (res.code == '00000') {
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
            this.getGroupPersons({"contractId": this.id});
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    deleteGroupPersons(){
      if(this.personsSel.length === 0){
        this.$message.error("请选择要删除的数据行")
        return
      }
      const ids=[]
      this.personsSel.forEach(v=>{
        ids.push(v.id)
      })

      this.$confirm('确认要删除选中的数据吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.deletePeContractsGroupPersons({ids:ids}).then(res => {
          if (res.code == '00000') {
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
            this.getGroupPersons({"contractId": this.id});
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },

    //分组
    regroup(row) {
      this.groupnamedialog = true
      let groupId = row.groupId;
      this.$axios.insertPeContractsGroupPersons({
        id: groupId
      }).then(res => {
        if (res.code == '00000') {
          this.$message({
            type: 'success',
            message: '分组成功!'
          });
          this.groupnamedialog = false;
          this.getGroupPersons({"contractId": this.id});
        }
      })
    },
    checkSign() {
      // 获取子组件form
      this.checkform = this.$refs.riskForm.$refs.riskFormRef.model;
      // console.log("子组件表单信息：",this.checkform)
      // 在这里验证
      this.$refs.riskForm.$refs.riskFormRef.validate((valid) => {
        if (valid) {
          this.$axios.updatePeCustomers({
            id: this.checkpersonid,
            ...this.checkform
          }).then(res => {
            if (res.code == '00000') {
              this.$message({
                type: 'success',
                message: res.msg
              })
              let ind = this.personList.findIndex(item => item.id == this.checkpersonid);
              this.personList[ind] = this.checkform;
            }
            console.log(res)
            this.compileis = false;
          })
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 编辑参检人员分组
    editGroupPersons(row) {
      // personList
      this.checkPerson = row.id
      // this.title = '参检人员编辑'
      this.$axios.getPeCustomersById({
        peCustomersId: row.id
      }).then(res => {
        if (res.code == '00000') {
          this.id = res.data.id
          this.queryform = res.data
          this.compileis = true;
        }
        // console.log("编辑参检人员分组",res)
      })
    },

    // 参检人员分组名称和id
    //文件校验方法
    beforeUpload(file) {
      // 通过split方法和fileArr方法获取到文件的后缀名
      let fileArr = file.name.split('.')
      let suffix = fileArr[fileArr.length - 1]
      //只能导入.xls和.xlsx文件
      if (!/(xls|xlsx)/i.test(suffix)) {
        this.$message('文件格式不正确')
        return false
      }
      //不能导入大小超过2Mb的文件
      if (file.size > 2 * 1024 * 1024) {
        this.$message('文件过大，请上传小于2MB的文件〜')
        return false
      }
      return true
    },
    //文件发生改变就会触发的事件
    uploadByJsqd(file) {
      console.log(this.id)
      //判断是否符合beforeUpload方法中的条件
      if (this.beforeUpload(file)) {
        this.fileList.name = file.name
        this.fileList.url = ''
        var formdata = new FormData()
        formdata.append('file', file.raw)
        formdata.append('id', this.id)
        //请求接口 formdata 传递参数
        this.$axios.importPerson(
            formdata
        ).then((res) => {
          if(res.code === '00000'){
            this.$message({
              message: res.msg,
              type: 'success'
            })
            // this.personList = res.data;
            this.getGroupPersons({"contractId": this.id});
          }
        })
      }
    },

		serchgroup(){
			this.$axios.getGroupTemplateList({}).then(res => {
			  if (res.code == '00000') {
					this.groupOptions = res.data
          this.groupOptions.forEach(v=>{
            this.groupMap[v.id]=v.name
          })
			  }
			})
		},
    selectGroup(e){
      this.groupform.groupName = this.groupMap[e]
    },
    // 分组相关
    addGroup() {
      // 点击添加触发新增合同分组
      // 同时添加分组和分组项目信息(peContractsGroupItemsList)
      if(this.id === null){
        this.$message.error("请先创建合同信息！")
        return
      }
      const req ={
        groupName:this.groupform.groupName,
        id:this.groupform.groupId,
        contractId:this.id
      }
      this.$axios.insertPeContractsGroupTemplate(req).then(res => {
        if (res.code == '00000') {
          this.$message({
            type: 'success',
            message: res.msg
          })
          // 根据合同查询分组信息
          this.queryGroupList(this.id);
        }
        this.groupform = {}
      })
    },
    editGroup(row){
      this.dialogroupedit = true
			this.editForm = Object.assign({}, row);
    },
    editgroupinfo() {
			this.$axios.updatePeContractsGroup({
				...this.editForm
			}).then(res=>{
				if(res.code == '00000'){
					this.$message({
					  type:'success',
					  message:res.msg
					})
					this.queryGroupList(this.editForm.contractId);
				}
				// console.log("保存修改合同分组列表：",res);
			})
			this.dialogroupedit = false;
		},
    // 年龄限制
    getage() {
      if (this.editForm.groupAge == 0) {
        this.editForm.ageRange = null
        this.ageRange = false
      } else {
        this.ageRange = true
      }
    },
    deletegroupinfo(row){
			this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
			  confirmButtonText: '确定',
			  cancelButtonText: '取消',
			  type: 'warning'
			}).then(() => {
			  this.$axios.deletePeContractsGroup({
			    id:row.id
			  }).then(res=>{
			    console.log(res)
			    if(res.code == '00000'){
			      this.$message({
			        type: 'success',
			        message: '删除成功!'
			      });
			      this.queryGroupList(row.contractId);
			    }
			  })
			}).catch(() => {
			  this.$message({
			    type: 'info',
			    message: '已取消删除'
			  });
			});
		},
    valuetitle(row){
      this.outerVisible1 = true
      this.examItemList({"barcodegroupId": row.id})
      this.medicalDetail(row.id)
      this.groupn = row.groupName
      this.groupid = row.id
      this.groupCur = row
      this.packageSearchForm.applyTo = row.groupIndx
    },
    // 查询合同分组
    queryGroupList(queryid) {
      this.$axios.queryGroupList({
        contractId: queryid
      }).then(res => {
        if (res.code == '00000') {
          // 暂时隐藏
          this.groupList = res.data
        }
      })
    },

    // 新建单位信息
    addCompany(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$axios.addEnterprise({
            name: this.formlist.name,
            otherName: this.formlist.otherName,
            property: this.formlist.property,
            domain: this.formlist.domain,
            linker: this.formlist.linker,
            linkTel: this.formlist.linkTel,
            email: this.formlist.email,
            mangeGrade: this.formlist.mangeGrade,
            address: this.formlist.address
          }).then(res => {
            console.log(this.formlist);
            if (res.code == '00000') {
              this.$message({
                type: 'success',
                message: res.msg
              })
              this.dialogFormVisible2 = false;
            }
            // console.log(res)
          })
        }
      })
    },
    // 单选
    selectCompany(selection, row) {
      this.companySel = row;
      if (selection.length > 1) {
        let del_row = selection.shift()
        this.$refs.multipleTable1.toggleRowSelection(del_row, false) // 用于多选表格，切换某一行的选中状态，如果使用了第二个参数，则是设置这一行选中与否（selected 为 true 则选中）
      }
    },
    // 单位列表保存
    choiceCompanyid() {
      this.enterpriseId = this.companySel.id;
      this.enterpriseName = this.companySel.name;
      this.dialogFormVisible3 = false;
      this.roleName = "";
    },
    // 搜索单位名称
    querycompany() {
      this.$axios.getEnterpriseList({
        name: this.roleName
      }).then(res => {
        if (res.code == '00000') {
          this.tableData3 = res.data.records
          // this.total = res.data.total
          // console.log("查询到的单位列表",res.data);
        }
      })
    },
    // 单位查询
    readEnterpriseList() {
      this.dialogFormVisible3 = true;
      this.title = "编辑合同";
      this.$axios.getEnterpriseList({}).then(res => {
        if (res.code == '00000') {
          this.tableData3 = res.data.records

        }
      })
    },

    // 全选
    handleSelectionChange(val) {
      this.multipleTablelist = val;
    },
    // 新建合同
    adddinglog() {
      this.id = null;
      this.title = '编辑合同';
      this.form = {status: 0};
      this.enterpriseId = "";
      this.enterpriseName = "";
      this.dialogFormVisible = true;
      this.form={}
      //为了不出现缓存的情况
      this.queryGroupList("ll")
      this.getGroupPersons({"contractId": "lo"});
      this.serchgroup()
    },

    // 左侧点击保存触发新增合同
    addContractinfo(formName) {
      let obj = Object.assign(this.form, {"enterpriseId": this.enterpriseId, "enterpriseName": this.enterpriseName})
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.id == null) {
            this.$axios.insertPeEnterpriseContracts(
                obj
            ).then(res => {
              console.log(this.form);
              if (res.code == '00000') {
                this.$message({
                  type: 'success',
                  message: res.msg
                })
                this.callbackdata = res.data
                this.id = res.data.id
                this.getqueryContract();
              }
            })
          } else {
            // 编辑合同
            this.$axios.updatePeEnterpriseContracts({
              id: this.id,
              ...this.form,
              enterpriseName: this.enterpriseName,
            }).then(res => {
              if (res.code == '00000') {
                this.$message({
                  type: 'success',
                  message: res.msg
                })
                // this.doGetList();
              }
              // console.log(res)
            })
          }
        } else {

        }
      })
    },
    // 条件查询合同列表

    activeContract() {
      this.$axios.updateImmediatelyEffect({
        id: this.id
      }).then(res => {
        if (res.code == '00000') {
          this.$message({
            type: 'success',
            message: res.msg
          })
          this.doGetList(this.formInline)
          this.dialogFormVisible = false
        }
      })
    },

    // 编辑合同
    handleClick(row, action) {
      this.action = action
      if(action==='edit'){
        this.title = '编辑合同'
        this.serchgroup()
      }
      if(action==='view'){
        this.title = '查看合同'
      }
      this.dialogFormVisible = true
      this.$axios.selectContractbyid({
        id: row.id
      }).then(res => {
        if (res.code == '00000') {
          this.id = res.data.id;
          this.form = Object.assign({}, row);
          this.enterpriseName = this.form.enterpriseName;
          this.queryGroupList(this.id);
          this.getGroupPersons({"contractId": this.id});
        }
      })
    },
    // 列表删除
    remove(row) {
      this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.deletePeEnterpriseContracts({
          id: row.id
        }).then(res => {
          if (res.code == '00000') {
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
            this.doGetList()
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    // 查询
    getexamItemList() {
      this.examItemList = []
      this.$axios.examItemList(this.examItemSearchForm).then(res => {
        if (res.code === '00000') {
          this.staffList = res.data.records
        }
      })
    },
    getRowKey(row) {
      return row.itemId || row.id
    },
    // 合计方法
    getSummaries() {
      this.selectedStaffList.forEach((item) => {
        if (item.price == null) {
          item.price = 0;
          this.originalprice += parseFloat(item.price);
        } else {
          this.originalprice += parseFloat(item.price);
        }
      });
      this.originalprice = this.originalprice.toFixed(2)
    },
    // 单选
    selectrow1(selection, row) {
      this.packagearr = row;
      if (selection.length > 1) {
        let del_row = selection.shift()
        this.$refs.multipleTable1.toggleRowSelection(del_row, false) // 用于多选表格，切换某一行的选中状态，如果使用了第二个参数，则是设置这一行选中与否（selected 为 true 则选中）
      }
    },
    // 穿梭框
    // 左边表格选中存入staffData
    handleStaffChange(rows) {
      this.staffCheckNum = rows.length
      this.staffData = []
      if (rows) {
        rows.forEach((row) => {
          if (row) {
            this.staffData.push(row)
          }
        })
      }
    },
    // 左->右(单选-全选)
    addStaff(type) {
      setTimeout(() => {
        // 清空选择
        this.$refs['staffTable'].clearSelection()
        this.$refs['selectedStaffTable'].clearSelection()
      }, 0)
      if (type === 'single') {
        this.staffData.forEach((item) => {
          this.selectedStaffList.push(item)
        })
        this.selectedStaffNum = this.selectedStaffList.length
        for (let i = 0; i < this.staffList.length; i++) {
          for (let j = 0; j < this.staffData.length; j++) {
            if (this.staffList[i].id === this.staffData[j].id) {
              this.staffList.splice(i, 1)
              this.staffNum = this.staffList.length
            }
          }
        }
      }
    },
    // 右边表格选中存入selectedStaffData
    handleSelectedStaffChange(rows) {
      this.selectedStaffCheckNum = rows.length
      this.selectedStaffData = []
      if (rows) {
        rows.forEach((row) => {
          if (row) {
            this.selectedStaffData.push(row)
          }
        })
      }
    },
    // 右->左(单选-全选)
    removeStaff(type) {
      setTimeout(() => {
        this.$refs['staffTable'].clearSelection()
        this.$refs['selectedStaffTable'].clearSelection()
      }, 0)
      if (type === 'single') {
        this.selectedStaffData.forEach((item) => {
          this.staffList.push(item)
          this.staffNum = this.staffList.length
        })
        // console.log('this.staffList', this.staffList)
        for (let i = 0; i < this.selectedStaffList.length; i++) {
          for (let j = 0; j < this.selectedStaffData.length; j++) {
            if (
                this.selectedStaffList[i] &&
                this.selectedStaffData[j] &&
                this.selectedStaffList[i].id === this.selectedStaffData[j].id
            ) {
              this.selectedStaffList.splice(i, 1)
              this.selectedStaffNum = this.selectedStaffList.length
            }
          }
        }
      }
      if (type === 'all') {
        this.selectedStaffList.forEach((item) => {
          this.staffList.push(item)
          this.staffNum = this.staffList.length
        })
        this.selectedStaffList = []
        this.selectedStaffNum = 0
      }
    },
    // 选择套餐
    setmeal() {
      this.setmealis = true;
      this.readPackageList();  //这里改成根据分组id获取套餐
    },
    // 选择套餐
    readPackageList() {
      this.$axios.queryPbPackagesList(this.packageSearchForm).then(res => {
        if (res.code == '00000') {
          this.packageList = res.data.records
        }
        // console.log(res.data,this.queryform)
      })
    },

    // 储存选择的套餐
    savemealis() {
      this.$axios.queryPackagItems({
        "packageId": this.packagearr.id
      }).then(res => {
        if (res.code == '00000') {
          // this.staffList = res.data.records
          let arr = res.data.examItemsDTOList;
          if (this.selectedStaffList.length === 0) {
            this.selectedStaffList = arr
          } else {
            this.selectedStaffList = this.selectedStaffList.concat(arr);
          }
          this.selectedStaffList.map(v=>{
            return {
              ...v,
            postType:"单位",
            payStatus:1,}
            })
        }
      })

      this.setmealis = false;
    },
    sendtotal() {
      let peContractsGroupItemsList = []
      this.selectedStaffList.forEach(item => {
        if (item.id != null) {
          peContractsGroupItemsList.push(
              {
                "applyTo": item.applyTo,
                "groupId": item.groupId,
                "itemId": item.id,
                "price": item.price,
                // "sequence": "显示序号"
              }
          )
        }
      })
      let obj = {
        "id": this.groupid,
        "packageName": this.packagearr.packageName,
        "packagePrice": this.packagearr.price,
        "discountPrice": this.originalprice,
        "peContractsGroupItemsList": peContractsGroupItemsList
      }

      this.$axios.updatePeContractsGroup(obj).then(res => {
        if (res.code == '00000') {
          this.queryGroupList(this.id);
        }
        this.outerVisible1 = false;
      })
    },

    // 消息提示
    open(msg) {
      this.$message(msg);
    },
    // 添加单项，删除单项
    addItem(row) {
      var flag = false;
      if (this.inspectionitemlistis.length == 0) {
        this.inspectionitemlistis.push(row);
      } else {
        this.inspectionitemlistis.some((item) => {
          if (item.id == row.id) {
            this.open("此项已存在，请勿重复添加！");
            flag = true;
            return true
          }
        })
        if (!flag) {
          this.inspectionitemlistis.push(row);
        }
      }
    },
    deleteItem(row) {
      this.inspectionitemlistis.some((item, i) => {
        if (item.itemCode == row.itemCode) {
          this.inspectionitemlistis.splice(i, 1);
          return true;
        }
      })
    },

    // 删除体检套餐
    deletetaocan() {
      // console.log('第1个数组',this.multipleSelection)
      // console.log('第2个数组',this.listgeren)
      this.multipleSelection.forEach(data => {
        this.listgeren.push(data);
        //通过两个数组的id进行对比过滤
        this.listgeren = this.listgeren.filter(item => item.id != data.id)
      })
    },

    // 合同编号自动生成
    getautoid() {
      const projectTime = new Date() // 当前中国标准时间
      const Year = projectTime.getFullYear() // 获取当前年份 支持IE和火狐浏览器.
      const Month = projectTime.getMonth() + 1 // 获取中国区月份
      let CurrentDate = String(Year);
      if (Month >= 10) { // 判断月份和几号是否大于10或者小于10
        CurrentDate += Month
      } else {
        CurrentDate += '0' + Month
      }
      return CurrentDate;

    }
  },
}
</script>

<style scoped>
.info_sel {
  display: flex;
  width: 100%;
}

.info_sel_l {
  width: 50%;
}

.info_sel_r {
  width: 50%;
  margin-left: 50px;
}

.list {
  display: flex;
}

/* .info_r{
	margin-left: 10px;
	width: ;
} */
.dwflex {
  display: flex;
}

.dwflex > div {
  width: 50%;
}

.newunit {
  margin-bottom: 20px;
  margin-left: 17%;
  width: 150px;
  color: black;
}

.ifunit /deep/ .el-input {
  width: 40%;
  margin-right: 5%;
}

.top_dialog /deep/ .el-dialog {
  margin-top: 3vh !important;
}

.el-select {
  width: 100%;
}

.el-select /deep/ .el-input__inner {
  width: 100%;
}

::v-deep .input_c .el-input__inner {
  width: 100%;
}

::v-deep .el-dialog__body {
  border-bottom: 1px solid #cccccc;
  margin: 0 20px;
  padding: 20px 20px 0px;
  /* padding: 20px; */
}

.date {
  text-align: right;
  color: #7F7F7F;
  font-weight: bold;
}

.info_l {
  /* width: 80%; */
  margin: 0px auto;
}

.info_l_input {
  width: 82%;
}


.info_sel_r_groupn {
  margin-left: 40px;
}

.form-row {
  overflow: hidden;
}

.form-col {
  float: left;
}


.info_sel_r_img {
  width: 180px;
  height: 220px;
  margin: 0px auto;
}

.avatar-uploader {
  margin: 0px auto;
  text-align: center;
}

.info_l /deep/ .el-select {
  width: 100%;
}

.info_l_head {
}

.el-table th > .cell {
  white-space: nowrap;
}


.tan_k {
  display: flex;
  justify-content: space-between;
}

.textarea {
  width: 350px;
  height: 120px;
}

.el-textarea /deep/ .el-textarea__inner {
  min-height: 89px;
  height: 89px;
}

.text_a {
  width: 50%;
  margin-left: 20px;
}

.text_a > span {
  width: 100%;
  display: inline-block;
  border-bottom: 1px solid #cccccc;
}

.add_jian {
  padding-top: 15px;

}

.add_jian > span {
  display: block;
  color: #3298D3;
  font-size: 8px;
  line-height: 24px;
}

::v-deep .el-dialog__body {
  border: 0px;
}

.tableTitle {
  padding-top: 10px;
}

.text-center {
  text-align: center !important;
}

.text-left {
  text-align: left !important;
}

.bg-blue {
  height: 500px;
  background-color: #CFE8F4;
  border: 1px solid #CFE8F4;
  overflow-y: auto;
}

.bg-grey {
  background-color: #F2F2F2;
}

.buttonAll {
  padding-bottom: 50px;
}

.text-red {
  color: #D9001B;
}

.mt-20 {
  margin-top: 20px;
}

.pt-20 {
  padding-top: 20px;
}

.pb-20 {
  padding-bottom: 20px;
}

.mar-10 {
  padding: 0 10px;
}

.check-style {
  margin: 10px 0 0 40px !important;
}

.staffButton {
  margin-top: 20px;
}

.nsm-right-top {
  display: inline;
  margin-left: 10px;
}

.pagination {
  text-align: center;
}

.nsm-bottom-line {
  margin-top: 5px;
  margin-bottom: 20px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  background-color: #fff;
}

.vmm {
  margin-top: 10px;
}

.disflex {
  display: flex;
  justify-content: space-between;
}

.main_box_title {
  background: #fff;
  padding: 10px;
}

.aside_box_title {
  margin: 0px 8px 10px;
  /* text-align: center; */
}

.header_top .el-divider--horizontal {
  margin-top: 0px;
}

.add_info .el-divider--horizontal {
  margin-top: 10px;
}

.add_info {
  display: flex;
  padding: 0px 20px;
}

.el-main {
  padding: 0px;
  padding-left: 20px;
}

.staff_form_btn {
}

.info_l {
  text-align: left;
  flex: 1;
}

.info_r {
  text-align: left;
  flex: 1;
  margin-left: 30px;
}

.info_l_input {
  width: 82%;
}

.info_l_button {
  margin-left: 10px;
}

.info_sel_r_groupn {
  margin-left: 40px;
}

.info_sel_r_group {
  margin-left: 10px;
}

.info_sel {
  display: flex;
}

.info_sel_l {
  width: 50%;
}

.info_sel_r {
  width: 50%;
  margin-left: 50px;
}

.info_sel_r_img {
  width: 180px;
  height: 220px;
  margin: 0px auto;
}

.avatar-uploader {
  margin: 0px auto;
  text-align: center;
}

.info_l /deep/ .el-select {
  width: 100%;
}

.info_l_head {
}

.pagination {
  text-align: center;
}

.top_dialog /deep/ .el-dialog {
  margin-top: 3vh !important;
}

.photog {
  width: 600px;
  height: 400px;
  margin: 10px auto;
}

.photog video {
  width: 600px;
  height: 400px;
}

.photog canvas {
  width: 600px;
  height: 400px;
}

.info_sel_s_butn {
  margin: 0px auto;
}

.info_sel_butn {
  margin-left: 20px;
}

.info_sel_s {
  margin-left: 20px;
}

.ldog_butn {
  width: 120px;
  height: 50px;
  margin: 0px auto;
}

.form_div {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  padding: 0px 30px;
}

.block {
  text-align: center;
}

.lai_div {
  margin-top: 20px;
  display: flex;
}

.lai_div_l {
  width: 480px;
}

.lai_div_l /deep/ .el-input--suffix {
  width: 400px;
}

.lai_div_r {
  margin-left: 20px;
}

.yvyue_div {
  display: flex;
  justify-content: space-between;
}

.yvyue_div button {
  width: 150px;
}

.options {
  position: relative;
}

.options_div {
  position: absolute;
  top: 5px;
  right: 10px;
  z-index: 99 !important;
}

/* 扫码交表 */
.smjb-top {
  padding: 20px 0;
  border-bottom: 1px solid #eee;
}

.smjbtablestyle {
  margin: auto;
}

.title1 {
  margin: 20px auto;
  width: 80%;
  font-size: 20px;
}

.smfooter {
  display: flex;
  justify-content: space-around;
  padding-top: 20px;
  font-size: 12px;
  color: #D9001B;
  border-top: 1px solid #eee;
}

.dfooter {
  padding-top: 30px;
  display: flex;
  justify-content: space-between;
}

.zyd-code {
  font-size: 28px;
}

.zyd-title {
  font-size: 32px;
  text-align: center;
}

.zyd-item {
  margin-top: 20px;
  font-size: 18px;
}

.fontstylekai, .adjusttable {
  font-family: "楷体";
}

.title4 {
  margin-top: 20px;
  padding: 15px 0;
  text-align: center;
  background-color: #f0f0f0;
}

.adjusttable {
  width: 100%;
  font-size: 18px;
}

.adjusttable td {
  padding: 20px 0;
  border-bottom: 1px solid #999;
}

.adjusttable td:nth-child(2) {
  width: 60%;
}

.adjusttable .el-checkbox__label {
  font-size: 18px !important;
}

.title-common {
  position: relative;
  padding: 30px 0;
  text-align: center;
  font-size: 26px;
  font-weight: normal;
}

.title-common span {
  position: absolute;
  right: 0;
}

/* 打印表单样式 */
.printinput /deep/ .el-input__inner {
  border: 0;
  border-bottom: 1px solid #333;
  border-radius: 0;
}

.jfnoticebottom {
  display: flex;
  margin: 20px 0 40px;
}

.jfnoticebottom span {
  flex: 1;
}
</style>
